<?= isset($header) ? $header : '' ?>

<link href="/css/bootstrap/dist/css/bootstrap.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="/css/bootstrap/dist/js/bootstrap.js"></script>
<script type="text/javascript" src="/css/bootstrap/js/modal.js"></script>
<script type="text/javascript" src="/css/bootstrap/dist/js/bootstrap.js"></script>


<script type="text/javascript" src="/js/demand.js"></script>
<script type="text/javascript" src="/js/address.js"></script>
<script type="text/javascript" src="/js/object_pair.js"></script>

<script type="text/javascript">
	$("document").ready(function() {
		
		$("#more").click(function(){
			$("#haha").toggle();	
		});
		
		$("a#disable_demand").click(function(){
			
			$(this).parent().parent().toggle() ;
			
		});
		
		//儲存結果
		$("button#save_result").click(function() {
			
			//alert( $("#demand_many").val() ); 
			//alert( $("#market_id").val() );
			
			$.ajax({
				type : "POST",
				url : "/pair/rec_object_pair_demand_result",
				data : {
						"ymdhis_mh5"	  	: $("#ymdhis_mh5").val(),
						"demand_many" 	: $("#demand_many").val(),
						"object_id"   	: $("#object_id").val() 
						},
				success : function(data) {
								
					//alert(data);
					alert('儲存成功');					
					
					
				}
			});
			 
		});
		
		
		
		
		
		
		
		
		
		

		$("input:checkbox").change(function() {

			var _this_id = $(this).attr('class');

			if ($(this).attr('checked')) {

				$("#" + _this_id).val("true");

			} else {
				$("#" + _this_id).val("false");
			}

			//alert($("#"+_this_id).val());
		});

		$("button:#re_pair").click(function() {
			
			$("button#save_result").hide();
			$("button#send_sms").hide();

			var _verify_code = $("#verify_code").val();
			var _val = $(this).val();

			$.ajax({
				type : "POST",
				url : "/pair/ajax_pair_result",
				data : $("form").serialize(),
				success : function(data) {

					//alert(data);
					$("#cc").html('');
					$("#cc").html(data);
					//$("#tablesorter-demo").tablesorter();
					
					
					$("a#disable_demand").click(function(){
			
						$(this).parent().parent().toggle() ;
						
					});

				},
				complete : function(data) {
					//$("#content_show").html('');
					//$("#content_show").html(data);
					//$("#tablesorter-demo").tablesorter();

					//alert(data);
				}
			});

		});
	});
</script>

<div class="container">
	<?php

	foreach ($object_info->result() as  $val) {
	//echo $val->object_id;
	?>

	<form>
		<input type="hidden" value="<?=$val->object_id?>"  	id="object_id" >
		<input type="hidden" value="object_pair_demand"  	name="type" >
		<table class="table" id="haha"  style="border: black 2px solid;border: black 2px solid;display: none; ">

			<tr class="info">
				<th style="border-bottom: black 2px solid;width: 80px; "> 物件類型</th>
				<td style="border-left: black 2px solid;border: black 2px solid; ">
				<div style="width:100%;">

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:100px;background-color: white;" >

						買賣
						<input type="radio" name="_type" value="type_sale"  style="margin:0px 0px 0px 0px; "
						<?=($val -> type_sale > 0) ? 'checked' : ''; ?> 
						 >

						租賃
						<input type="radio" name="_type"  value="type_rent"  style="margin:0px 0px 0px 0px; "
						<?=($val -> type_rent > 0) ? 'checked' : ''; ?> 
						>
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;max-width:300px;background-color: white;">
						<input type="checkbox"  class="object_usage_flag" style="margin: 0px 0px 0px 4px;"
						<?=(strlen($val -> object_usage) > 2) ? 'checked' : ''; ?> >
						物件用途
						<input type="hidden" name="object_usage_flag" id="object_usage_flag" value="<?=(strlen($val -> object_usage) > 2) ? 'true' : 'false' ?>">
						<input type="text"    value="<?=($val -> object_usage)?$val -> object_usage:''  ?>" name="object_usage" id="object_usage" style="width:160px;margin-left: 10px;">
					</div>
				</div></td>
			</tr>

			<tr class="success">
				<th style="border-bottom: black 2px solid; "> 面積</th>
				<td style="border-left: black 2px solid;border: black 2px solid; ">
				<div style="width:100%;">

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:200px;background-color: white;" >
						<input type="checkbox" class="building_area_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> building_area > 0) ? 'checked' : ''; ?> >
						建物面積
						<input type="hidden" value="<?=($val -> building_area) ? 'true' : 'false' ?>" id="building_area_flag" name="building_area_flag">
						<input type="text" value="<?=$val -> building_area ?>"  name="building_area" id="building_area" style="width:60px;margin-left:10px; ">
						坪

					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;max-width:200px;background-color: white;">
						<input type="checkbox"  class="stakeholders_land_area_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> stakeholders_land_area > 0) ? 'checked' : ''; ?> >
						土地面積
						<input type="hidden" name="stakeholders_land_area_flag" id="stakeholders_land_area_flag" value="<?=($val -> stakeholders_land_area > 0) ? 'true' : 'false' ?>">
						坪
						<input type="text"    value="<?=$val -> stakeholders_land_area ?>" name="stakeholders_land_area" id="stakeholders_land_area" style="width:60px;margin-left: 10px;">
						坪
					</div>

					

				</div></td>
			</tr>

			<tr class="info">
				<th  style="border-bottom: black 2px solid; ">價格</th>
				<td style="border-left: black 2px solid;border-bottom: black 2px solid; ">
				<div style="width:100%;">
					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:190px;background-color: white;">
						<input type="checkbox"  class="sale_total_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> sale_total > 0) ? 'checked' : ''; ?> >
						總預算
						<input type="hidden" name="sale_total_flag"  id="sale_total_flag"  value="<?=($val -> sale_total > 0) ? 'true' : 'false' ?>" >
						<input type="text" name="sale_total" id="sale_total" style="width:60px;margin:0px 10px 0px 10px;" value="<?=$val -> sale_total ?>" >
						萬

					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:190px;background-color: white;">

						<input type="checkbox"  class="sale_housing_unit_price_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> sale_housing_unit_price > 0) ? 'checked' : ''; ?> >

						每坪預算
						<input type="hidden" name="sale_housing_unit_price_flag"  id="sale_housing_unit_price_flag" value="<?=($val -> sale_housing_unit_price > 0) ? 'true' : 'false' ?>"  >
						<input type="text"   name="sale_housing_unit_price" id="sale_housing_unit_price" value="<?=$val -> sale_housing_unit_price ?>"  style="width:60px;margin: 0px 10px 0px 10px;">
						萬
					</div>

				</div></td>
			</tr>

			<tr class="warning">
				<th style="border-bottom: black 2px solid;width:60px; "> 區域</th>
				<td style="border-left: black 2px solid;border-bottom: black 2px solid; ">
				<div style="width:100%;">
					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;
					width:340px;max-width:340px;background-color: white;">
						<input type="checkbox"  class="area_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> area) ? 'checked' : ''; ?>
						>
						重點區域

						<input type="hidden" name="area_flag" id="area_flag"   value="<?=$val -> area ?>" value="<?=($val -> area) ? 'true' : 'false' ?>" >
						<input type="text"   name="area"      id="area" style="width:220px;margin-left: 20px;"  value="<?=$val -> area ?>" onclick="show_emphasis_area('area')" >
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px;
					border-style:solid;margin:3px;width:340px;max-width:340px;background-color: white;">

						<input type="checkbox"   class="building_name_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> building_name) ? 'checked' : ''; ?>
						>

						指定大樓
						<input type="hidden" name="building_name_flag" id="building_name_flag"  value="<?=($val -> building_name) ? 'true' : 'false' ?>"   >
						<input type="text" name="building_name" id="building_name" style="width:220px;margin-left: 20px;" value="<?=$val -> building_name ?>"  onclick="show_building_name('building_name')"  >
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;
					width:340px;max-width:340px;background-color: white;">
						<input type="checkbox"  class="house_building_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> house_building) ? 'checked' : ''; ?>
						>
						路段
						<input type="hidden" name="house_building_flag" id="house_building_flag" style="width:260px;margin-left: 20px;"  value="<?=($val -> house_building) ? 'true' : 'false' ?>" >
						<input type="text" name="house_building" id="house_building" style="width:260px;margin-left: 20px;"  value="<?=$val -> house_building ?>" onclick="show_address('house_building');" >

					</div>

				</div></td>
			</tr>

			<tr class="info">
				<th  style="border-bottom: black 2px solid; ">屋況樓層</th>
				<td style="border-left: black 2px solid;border-bottom: black 2px solid; ">
				<div style="width:100%;">
					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:190px;background-color: white;">
						<input type="checkbox"  class="year_of_construction_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> year_of_construction > 0) ? 'checked' : ''; ?> >
						屋齡
						<input type="hidden" name="year_of_construction_flag" id="year_of_construction_flag"  value="<?=($val -> year_of_construction > 0) ? 'true' : 'false' ?>" >
						<input type="text" name="year_of_construction" id="year_of_construction" style="width:60px;margin:0px 10px 0px 10px;" value="<?=$val -> year_of_construction ?>" >
						年

					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:190px;background-color: white;">

						<input type="checkbox"  class="floor_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> floor > 0) ? 'checked' : ''; ?> >

						指定樓層
						<input type="hidden"  name="floor_flag" id="floor_flag" value="<?=($val -> floor > 0) ? 'true' : 'false' ?>"  >
						<input type="text"   name="floor" id="floor" value="<?=$val -> floor ?>"  style="width:60px;margin: 0px 10px 0px 10px;">
						樓
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:290px;background-color: white;">

						<input type="checkbox"  class="windows_flag" style="margin: 0px 0px 0px 4px;"
						<?=(strlen($val -> windows) > 2) ? 'checked' : ''; ?> >

						落地窗座向
						<input type="hidden" name="windows_flag" id="windows_flag" value="<?=(strlen($val -> windows) > 2) ? 'true' : 'false' ?>"  >
						<input type="text"   name="windows" id="windows" value="<?=$val -> windows ?>"  style="width:160px;margin: 0px 10px 0px 10px;">
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:290px;background-color: white;">

						<input type="checkbox"   class="household_door_flag" style="margin: 0px 0px 0px 4px;"
						<?=(strlen($val -> household_door) > 2) ? 'checked' : ''; ?> >

						該戶座向
						<input type="hidden" name="household_door_flag"  id="household_door_flag" value="<?=(strlen($val -> household_door) > 2) ? 'true' : 'false' ?>"  >
						<input type="text"   name="household_door" id="household_door" value="<?=$val -> household_door ?>"  style="width:160px;margin: 0px 10px 0px 10px;">
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:290px;background-color: white;">

						<input type="checkbox"  class="building_entrance_flag" style="margin: 0px 0px 0px 4px;"
						<?=(strlen($val -> building_entrance) > 2) ? 'checked' : ''; ?> >

						大樓座向
						<input type="hidden" name="building_entrance_flag" id="building_entrance_flag" value="<?=(strlen($val -> building_entrance) > 2) ? 'true' : 'false' ?>"  >
						<input type="text"   name="building_entrance" id="building_entrance" value="<?=$val -> building_entrance ?>"  style="width:160px;margin: 0px 10px 0px 10px;">
					</div>

				</div></td>
			</tr>

			<tr class="warning">
				<th style="border-bottom: black 2px solid;width:60px; "> 其他條件 </th>

				<td style="border-left: black 2px solid;border-bottom: black 2px solid; ">
				<div style="width:100%;">
					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;
					width:170px;max-width:340px;background-color: white;">
						<input type="checkbox"  class="parking_area_number_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> with_parking_number > 0) ? 'checked' : ''; ?> >
						車位數

						<input type="hidden" name="parking_area_number_flag" id="parking_area_number_flag"   value="<?=($val -> with_parking_number) ? 'true' : 'false' ?>" >
						<input type="text"   name="parking_area_number"      id="parking_area_number" style="width:60px;margin-left: 20px;"  value="<?=$val -> with_parking_number ?>" >
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px;
					border-style:solid;margin:3px;width:170px;max-width:340px;background-color: white;">

						<input type="checkbox"  class="indoor_pattern_house_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> indoor_pattern_house > 0) ? 'checked' : ''; ?> >

						房數
						<input type="hidden" name="indoor_pattern_house_flag" id="indoor_pattern_house_flag"  value="<?=($val -> indoor_pattern_house) ? 'true' : 'false' ?>"   >
						<input type="text" name="indoor_pattern_house" id="indoor_pattern_house" style="width:60px;margin-left: 20px;" value="<?=$val -> indoor_pattern_house ?>"  >
					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;
					width:170px;background-color: white;">
						<input type="checkbox"  class="indoor_pattern_hall_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> indoor_pattern_hall > 0) ? 'checked' : ''; ?> >
						廳數
						<input type="hidden" name="indoor_pattern_hall_flag" id="indoor_pattern_hall_flag" style="width:260px;margin-left: 20px;"  value="<?=($val -> indoor_pattern_hall) ? 'true' : 'false' ?>" >
						<input type="text" name="indoor_pattern_hall" id="indoor_pattern_hall" style="width:60px;margin-left: 20px;"  value="<?=$val -> indoor_pattern_hall ?>" >

					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;
					width:340px;max-width:170px;background-color: white;">
						<input type="checkbox"  class="indoor_pattern_guard_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> indoor_pattern_guard > 0) ? 'checked' : ''; ?> >
						衛數
						<input type="hidden" name="indoor_pattern_guard_flag" id="indoor_pattern_guard_flag" style="width:160px;margin-left: 20px;"  value="<?=($val -> house_building) ? 'true' : 'false' ?>" >
						<input type="text"   name="indoor_pattern_guard" id="indoor_pattern_guard" style="width:60px;margin-left: 20px;"  value="<?=$val -> indoor_pattern_guard ?>" >

					</div>

					<div  style="padding:3px;float:left;border-width:1px; height:32px; border-style:solid;margin:3px;width:170px;background-color: white;">
						<input type="checkbox"  class="indoor_pattern_suite_flag" style="margin: 0px 0px 0px 4px;"
						<?=($val -> indoor_pattern_suite > 0) ? 'checked' : ''; ?> >
						套房數
						<input type="hidden" name="indoor_pattern_suite_flag" id="indoor_pattern_suite_flag" style="width:260px;margin-left: 20px;"  value="<?=($val -> indoor_pattern_suite) ? 'true' : 'false' ?>" >
						<input type="text" name="indoor_pattern_suite" id="indoor_pattern_suite" style="width:60px;margin-left: 20px;"  value="<?=$val -> indoor_pattern_suite ?>" >

					</div>

				</div></td>
			</tr>

		</table>
	</form>

	<div style="margin: 0px 0px 10px 0px">
		
		
		<button type="button" class="btn btn-success" id="re_pair">
			重新配對
		</button>
		
		<button type="button" class="btn btn-success" id="save_result">
			儲存結果
		</button>

		<button type="button" class="btn btn-success" id="send_sms">
			發送簡訊
		</button>
		
		<button type="button" class="btn btn-success" id="more">
			進階條件
		</button>
		
		
	</div>
	<?php
	}
	?>

	<script type="text/javascript">
		$("document").ready(function() {
			$("#fuckingshow").click(function() {
				$(".fuckingshow").toggle();
			});
		});
	</script>

	

	<link rel="stylesheet" href="/js/table/style.css" type="text/css" media="print, projection, screen" />
	

	<script type="text/javascript">
		$(function() {
			
			$("#tablesorter-demo").tablesorter();
			
		});
	</script>

	<div id='cc'>		
		<?php
		 
		echo $result_page;		
		foreach($show_box_infos as $kk => $html_box){
			echo $html_box;			
		}
		?>
	</div>

</div>

<?php
$this -> load -> view('demand/showbox');
$this -> load -> view("showbox/address");
?>
